package com.dlwx.parttimetalent.adapter;

import android.content.Context;
import android.content.Intent;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.dlwx.parttimetalent.R;
import com.dlwx.parttimetalent.bean.MyPublishBean;
import com.dlwx.parttimetalent.ui.AttentionUser2Activity;

/**
 * Created by Administrator on 2017/11/21.
 */

public class OrderPublishAdapter extends ListBaseAdapter<MyPublishBean.BodyBean> {
    private  Context context;
    public OrderPublishAdapter(Context context) {
        super(context);
        this.context=context;
    }

    @Override
    public int getLayoutId() {
        return R.layout.item_order_publish;
    }

    @Override
    public void onBindItemHolder(SuperViewHolder holder, final int position) {
        final MyPublishBean.BodyBean bean = getDataList().get(position);
        ImageView image_header=holder.getView(R.id.image_header);
        TextView tv_name=holder.getView(R.id.tv_name);
        TextView tv_num=holder.getView(R.id.tv_num);
        TextView tv_price=holder.getView(R.id.tv_price);
        TextView tv_address=holder.getView(R.id.tv_address);
        TextView tv_time=holder.getView(R.id.tv_time);
        TextView tv_ybm=holder.getView(R.id.tv_ybm);
        Glide.with(context).load(bean.getHeadurl()).into(image_header);
        tv_name.setText(bean.getWorktitle());
        tv_price.setText(bean.getPrice());
        tv_num.setText("人数："+bean.getNumber()+"人");
        tv_address.setText("距离："+bean.getRange());
        if(bean.getTimetype()==1){
            tv_time.setText("有效时间倒计时："+bean.getDjs()+"天");
        }else{
            tv_time.setText("有效时间倒计时：3天"+bean.getDjs()+"小时");
        }
        tv_ybm.setText(bean.getBmnumber()+"");
        image_header.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent i=new Intent(context,AttentionUser2Activity.class);
                i.putExtra("listId",bean.getReleaseuserid()+"");
                context.startActivity(i);
            }
        });
    }
}
